<?php
   
/**
 * Mapper for tparameters
 * 
 * @author Martin Grossmann <snake.aas@gmail.com>
 * @version 1.0
 * @package Mappers
 *
 * @property string $Parameter Name of assignable parameter. 20 chars max
 * @property string $Unit Unit of parameter. Can be null. 5 chars max
 * 
 * @entity 
 * @table(name="tparameters", indexes={@index(name="TParameters_Units_FK", columns="Unit")})
 */     
class Parameter {
  /**
   * Name of assignable parameter
   * 
   * @access private
   * @var string
   * 
   * @Id
   * @column(name="Parameter", type="string", length=20)
   */
   private $parameter;
     
   //@column(name="Unit", type="string", length=5, nullable=true)
  /**
   * Unit of parameter. Can be null
   * 
   * @access private
   * @var string
   * 
   * @manyToOne(targetEntity="Unit")
   * @joinColumn(name="Unit", referencedColumnName="Unit")
   */
   private $unit;
     

  public function __get($name) {
 
    switch($name) {
      case "Parameter": 
        return $this->parameter;
        break;
    
      case "Unit": 
        return $this->unit;
        break;
      
      default: 
        throw new EntityException(sprintf(T_("Trying to get undefined property")." ", $name));
    }
  }
  
  public function __set($name, $value) {

    switch($name) {
      case "Parameter": 
        $this->parameter = Validations::validateString($value, 20, null, false);
        break; 

      case "Unit": 
        $this->unit = Validations::ValidateObject($value, 'Unit');
        break; 

      default: 
        throw new EntityException(sprintf(T_("Trying to set undefined property")." ", $name));
    }
  }  
  
}